using Eleven_TwoWeek_HD.BLL;
using Eleven_TwoWeek_HD.DAL;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddDbContext<Mycontext>(D=>D.UseSqlServer(builder.Configuration.GetConnectionString("db")));
builder.Services.AddControllers().AddJsonOptions(P=>P.JsonSerializerOptions.PropertyNamingPolicy=null);
builder.Services.AddScoped<StoresDal>();
builder.Services.AddScoped<StoresBll>();
builder.Services.AddScoped<VouchersBll>();
builder.Services.AddScoped<VouchersDal>();
var app = builder.Build();

app.UseCors(K => { K.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin(); });

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
